package com.zhangxin.aiInterview.model.enums;

import io.swagger.models.auth.In;
import lombok.Getter;
import org.apache.commons.lang3.ObjectUtils;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * 难度枚举
 */
@Getter
@Deprecated
public enum DifficultyEnum {

    SIMPLE("简单", 0),
    MEDIUM("中等", 1),
    DIFFICULT("困难", 2);

    private final String text;

    private final Integer value;

    DifficultyEnum(String text, Integer value) {
        this.text = text;
        this.value = value;
    }

    /**
     * 获取值列表
     *
     * @return
     */
    public static List<Integer> getValues() {
        return Arrays.stream(values()).map(item -> item.value).collect(Collectors.toList());
    }

    /**
     * 根据 value 获取枚举
     *
     * @param value
     * @return
     */
    public static DifficultyEnum getEnumByValue(Integer value) {
        if (ObjectUtils.isEmpty(value)) {
            return null;
        }
        for (DifficultyEnum anEnum : DifficultyEnum.values()) {
            if (Objects.equals(anEnum.getValue(), value)) {
                return anEnum;
            }
        }
        return null;
    }

}
